class MyRange:
    def __init__(self, start, stop=None, step=1):
        if stop is None:
            self.start = 0
            self.stop = start
        else:
            self.start = start
            self.stop = stop
        self.step = step
        self.current = self.start

    def __iter__(self):
        return self

    def __next__(self):
        if self.step > 0 and self.current >= self.stop:
            raise StopIteration
        elif self.step < 0 and self.current <= self.stop:
            raise StopIteration
        result = self.current
        self.current += self.step
        return result

# 模拟 range(5)
for i in MyRange(5):
    print(i)

# 模拟 range(1, 6)
for j in MyRange(1, 6):
    print(j)

# 模拟 range(0, 10, 2)
for k in MyRange(0, 10, 2):
    print(k)